package day09demo2;

public class GirlFriendTest {
    public static void main(String[] args) {
        GirlFriend[] arr = new GirlFriend[4];
        GirlFriend g1 = new GirlFriend("慧慧",20,"萌妹子","魔法");
        GirlFriend g2 = new GirlFriend("日富美",18,"女学生","啊哈哈");
        GirlFriend g3 = new GirlFriend("梓",16,"女学生","枪械");
        GirlFriend g4 = new GirlFriend("小春",14,"女学生","奇怪的书");
        arr[0] = g1;
        arr[1] = g2;
        arr[2] = g3;
        arr[3] = g4;
        int sum = 0 ;
        for (int i = 0; i < arr.length; i++) {
            GirlFriend girlFriend = arr[i];
            sum = sum + girlFriend.getAge();
        }
        int avg = sum / arr.length;
        int count = 0;

        for (int i = 0; i < arr.length; i++) {
            GirlFriend gf = arr[i];
            if (gf.getAge() < avg){
                System.out.println(gf.getName()+","+gf.getAge()+","+gf.getGender()+","+gf.getHobby());
                count++;
            }
        }
        System.out.println("比平均年龄低的有"+ count + "个");


    }
}
